package com.java.simple.smallspring.jdbc.core;

import lombok.RequiredArgsConstructor;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Objects;

/**
 * @author zhoujunlin
 * @date 2022年11月19日 19:10
 * @desc
 */
@RequiredArgsConstructor
public class ArgumentPreparedStatementSetter implements PreparedStatementSetter {

    private final Object[] args;

    @Override
    public void setValues(PreparedStatement ps) throws SQLException {
        if (Objects.nonNull(args)) {
            for (int i = 1; i <= args.length; i++) {
                ps.setObject(i, args[i - 1]);
            }
        }
    }

}
